% This script generates Figure 7 in the manuscript.
% The figure plots labor's share of value added in manufacturing in the
% data and in the model (benchmark parameterization with labor conflict and
% counterfactural experiment with no labor conflict).
%% Load data and model-generated results from benchmark calibration and counterfactual experiments.
clearvars;
cd ..
cd ./quantitative_model
BM = load('solution_model_BM.mat');
Conflict = load('solution_model_CF_no_intl_forces.mat');
Intl = load('solution_model_CF_no_conflict.mat');
Neither = load('solution_model_CF_neither.mat');
EB = load('CF_equally_bad.mat');
cd ..
cd ./replicate_figures
% load_data;
Data = table2array(readtable('time_series_shares.xlsx','Range','C30:BA31'));
year = 1950:1:2000;

% Calculate series
nRBgoods = BM.nRBgoods;
kappa = BM.kappa;

DataType = {'Compensation Share','Wages and Salaries Share'};
Spec = {'Benchmark Model','Conflict Only','Intl Forces Only','No Conflict or Intl Forces','Unions Equally Powerful'};

labor_share_RB = 100.*shiftdim(1 + sum(BM.rent_t(1,1:nRBgoods,:),2) - kappa*sum(BM.strike_t(1,1:nRBgoods,:).*BM.l_t(1:2,1:nRBgoods,:),[1 2]))./BM.GDP_1(:,1);
labor_share_RB(:,2) = 100.*shiftdim(1 + sum(Conflict.rent_t(1,1:nRBgoods,:),2) - kappa*sum(Conflict.strike_t(1,1:nRBgoods,:).*Conflict.l_t(1:2,1:nRBgoods,:),[1 2]))./Conflict.GDP_1(:,1);
labor_share_RB(:,3) = 100.*shiftdim(1 + sum(Intl.rent_t(1,1:nRBgoods,:),2) - kappa*sum(Intl.strike_t(1,1:nRBgoods,:).*Intl.l_t(1:2,1:nRBgoods,:),[1 2]))./Intl.GDP_1(:,1);
labor_share_RB(:,4) = 100.*shiftdim(1 + sum(Neither.rent_t(1,1:nRBgoods,:),2) - kappa*sum(Neither.strike_t(1,1:nRBgoods,:).*Neither.l_t(1:2,1:nRBgoods,:),[1 2]))./Neither.GDP_1(:,1);
labor_share_RB(:,5) = 100.*shiftdim(1 + sum(EB.rent_t(1,1:nRBgoods,:),2) - kappa*sum(EB.strike_t(1,1:nRBgoods,:).*EB.l_t(1:2,1:nRBgoods,:),[1 2]))./EB.GDP_1(:,1);

labor_share_agg = BM.labor_share_t;
labor_share_agg(:,2) = Conflict.labor_share_t;
labor_share_agg(:,3) = Intl.labor_share_t;
labor_share_agg(:,4) = Neither.labor_share_t;
labor_share_agg(:,5) = EB.labor_share_t;
%% Figure 7: Labor's Share of Value Added in Manufacturing
% Note: 1998-2000 data omitted due to switch from SIC to NAICS codes in 1997.
figure(7)
plot(year(1:end-3),Data(1,1:end-3),LineStyle='-',LineWidth = 2,Color='k');
text(1985,72,'Data','FontSize',13);
hold on
plot(year,BM.labor_share_t,LineStyle='--',LineWidth = 2,Color='k');
text(1975,68,'Model','FontSize',13);
hold on
plot(year,Intl.labor_share_t,LineStyle=':',LineWidth = 2,Color='k');
text(1971,62,'Model, no conflict','FontSize',13);
xlim([1949 2001]);
xticks(1950:10:2000);
ylim([54 81]);
yticks(55:5:80);
set(gca,'box','off','TickDir','out','Fontsize',14);
xline(2001,'k');
yline(81,'k');
ylabel('Labor Share of Income','Fontsize',14);
grid on
hold off
%% Save Figure 7 in PDF and EPS file formats.
saveas(gcf,'fig7.pdf');
saveas(gcf,'fig7','epsc');